<template>
  <div>
    <div class="shcar_item" v-for="(item,index) in tableData" :key="index">
      <div style="display:flex;align-items:center;">
        <img
          style="width:30px;height:30px;border-radius: 50%;"
          :src="item.product.image"
          alt
        />
        <div style="font-size:14px;font-weight:500;margin-left:25px;">{{item.product.storeName}}</div>
      </div>
      <!-- <div>
        <span style="font-size:14px;color:#ccc"> ￥{{item.product.price}} x{{item.cartNum}}</span>
      </div> -->
    </div>
  </div>
</template>
<script>
import { cartList, deleteCart, cartNumplus } from "../api/api";

export default {
  data() {
    return {
      num: 1,
      tableData: []
    };
  },
 
  created() {
    this.getCartList();
    this.$bus.$on('updataCart',()=>{
      this.getCartList()
    })
  },
  beforeDestroy(){
    this.$bus.$off('updataCart')
  },
  methods: {
    handleSelectionChange() {},
    
    async getCartList() {
      const { data } = await cartList({
        uid: this.$store.getters["userId"]
      });
      this.$store.commit('setShopcartCount',data.length)
      this.tableData = data.slice(0,3);
    }
  }
};
</script>
<style>
.shcar_item {
  width: 100%;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding: 15px;
  box-sizing: border-box;
  justify-content: space-between;
}
</style>